/*
* @Author: sc
* @Date:   2019-01-08 00:12:41
* @Last Modified by:   sc
* @Last Modified time: 2019-01-11 21:05:09
*/
import React from 'react'

class TableList extends React.Component{
	constructor(props){
		super(props);
	}
	render(){
		let tableHeader = this.props.tableHeads.map(
			(tableHead, index) => {
				if(typeof tableHead === 'object'){
					return (
						<th key={index} width={tableHead.width}>{tableHead.name}</th>
					)
				}else if(typeof tableHead === 'string'){
					return (
						<th key={index}>{tableHead}</th>
					)
				}
			}
		);
		let tableBody = this.props.children;
		return(
			<div className="row">
				<div className="col-md-12">
					<table className="table table-striped table-bordered">
						<thead>
							<tr>
								{tableHeader}								
							</tr>
						</thead>
						<tbody>
							{tableBody}
						</tbody>
					</table>
				</div>
			</div>
		);
	}
}

export default TableList;